package com.sky.controller.User;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.*;

@RestController("Useshopcontroller")
@RequestMapping("/user/shop")
@Api(tags = "店铺操作接口")
@Slf4j
public class ShopController {
    private static final String SHOP_STATUS= "SHOP_STATUS";
    @Autowired
    private RedisTemplate redisTemplate;
    /**
     * 获取店铺状态
     * @return
     */
     @ApiOperation("客户端获取店铺状态")
        @GetMapping("/status")
     public Result<Integer> getShopStatus() {
         ValueOperations valueOperations = redisTemplate.opsForValue();
         Integer status = (Integer) valueOperations.get(SHOP_STATUS);
         log.info("店铺{}:", status==1?"营业":"休息");
         return Result.success(status);
     }

}
